<template>
	<view calss='all-part'>
		<view class="courier-number">
			<span>发货数量</span>
			<radio-group @change="radioChange" class="radio-group">
				<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
					<view class="radio">
						<radio :value="item.value" :checked="index === current" color="#077840" />
					</view>
					<view class="name">{{item.name}}</view>
				</label>
			</radio-group>
		</view>
		  <view class="submit" @click="submit">{{current==0? '提交':'下一步'}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: [{
						value: '1',
						name: '全部发货'
					},
					{
						value: '2',
						name: '发货部分',
						
					},
				],
				current: 0,
				cid:0,
				order_id:''
			}
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
		      this.cid =option.id
			  this.status = option.status
			  this.order_id=option.order_id
			  console.log(this.status);
			console.log(this.cid);
		   },
		methods: {
			// 单选按钮点击事件
			radioChange: function(evt) {
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.target.value) {
						this.current = i;
						break;
					}
				}
			},
			submit:function(){
				if(this.current ==0){
					// 全部发货
					this.api.orderDelivery ({
						type:0,
						order_id:this.cid,
						uid:uni.getStorageSync('uid')
					}).then(res=>{
							console.log(res);
						this.tui.toast(res.data.data)
						uni.$emit('updateOrderList')
						// uni.showToast({
						// title: '发货成功',
						// duration: 2000
						// })
						console.log(this.status);
						if(this.status==4) {
							uni.reLaunch({
								url:'../../orderList?status=4'
							})
						}else {
							uni.reLaunch({
								url:'../../orderList?status=5'
							})
						}
					}).catch(err=>{
									 
					})
					// // 状态改变
					// this.api.toShipment ({
					// 	order_id:this.cid
					// }).then(res=>{
					// 		console.log(res);
					// 	// this.tui.toast('提交成功')
					// }).catch(err=>{
									 
					// })
					
				}else{
					console.log(123)
					// 部分发货
					uni.navigateTo({
						url:'../deliveryNumber/deliveryNumber?status='+this.status +'&cid='+this.cid+'&order_id='+this.order_id 
					})
				}
				
			}
		}
	}
</script>

<style lang="less" scoped>
	page {
		background-color: #F9F9F9;
	}
	.courier-number {
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		padding-left: 30rpx;
		line-height: 100rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		margin-bottom: 20rpx;
		.radio-group {
			display: inline-block;
	
			view {
				display: inline-block;
	
			}
	
			.radio {
				margin-left: 30rpx;
			}
	
			.name {
				margin-right: 50rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
			}
		}
	}
	.submit {
		width: 630rpx;
		height: 96rpx;
		background: #077840;
		border-radius: 8rpx;
		margin: 0 auto;
		font-size: 32rpx;
		line-height: 96rpx;
		text-align: center;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		margin-top: 234rpx;
	
	}
</style>
